package com.hippo.core.service;

import com.alibaba.fastjson.JSONObject;
import com.hippo.core.dao.ProjectDao;
import com.hippo.core.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: hippo
 */
@Service
public class ProjectService {

    @Autowired
    private ProjectDao projectDao;

    public JSONObject getProjectList(JSONObject jsonObject) {
        CommonUtil.fillPageParam(jsonObject);
        int count = projectDao.countProject(jsonObject);
        List<JSONObject> list = projectDao.getProjectList(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
    }

    public JSONObject addProject(JSONObject data) {
        return CommonUtil.response(projectDao.addProject(data));
    }

    public JSONObject deleteProject(String id) {
        return CommonUtil.response(projectDao.deleteProject(id));
    }

    public JSONObject updateProject(JSONObject data) {
        return CommonUtil.response(projectDao.updateProject(data));
    }

    public JSONObject getProjectDropdown(String projectMember) {
        return CommonUtil.successPage(projectDao.getProjectDropdown(projectMember));
    }


}
